package com.yetm.servie.impl;

import com.yetm.dao.UserDao;
import com.yetm.servie.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

//<bean id="userService" class="com.yetm.servie.impl.UserServiceImpl">
//@Component
@Service("userService")
public class UserServiceImpl implements UserService {

    @Value("${jdbc.url}")
    private String url;

    //<property name="userDao" ref="userDao" />
    //@Autowired //按照类型从spring容器匹配
    //@Qualifier("userDao") //按照名称从spring容器中匹配，结合@Autowired一起使用
    @Resource(name = "userDao") //相当于@Autowired + @Qualifier
    private UserDao userDao;

    public void setUserDao(UserDao userDao) {
        this.userDao = userDao;
    }

    @Override
    public void show() {
        System.out.println(url);
        userDao.show();
    }
}
